<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改库存')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-stock-edit" th:object="${wWareStock}">
            <input name="stockId" th:field="*{stockId}" type="hidden">
            <div class="form-group">    `
                <label class="col-sm-3 control-label">入库单号：</label>
                <div class="col-sm-8">
                    <input name="inStockNumber" th:field="*{inStockNumber}" class="form-control" type="text" readonly>
                </div>
            </div>
            <div class="form-group" hidden="hidden">
                <label class="col-sm-3 control-label">入库日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="inStockDate" th:value="${#dates.format(wWareStock.inStockDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                    </div>
                </div>
            </div>
            <div class="form-group" hidden="hidden">
                <label class="col-sm-3 control-label">入库人：</label>
                <div class="col-sm-8">
                    <input name="inStockPerson" th:field="*{inStockPerson}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">数量：</label>
                <div class="col-sm-8">
                    <input name="stockQty" th:field="*{stockQty}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">仓库名称：</label>
                <div class="col-sm-8">
                    <select class="form-control" name="" th:onchange="chosseVal()" id="selectWare">
                        <option>---请选择---</option>
                        <option th:each="wh:${warehouse}" th:value="${wh.wareHouseId}">[[${wh.name}]]</option>
                    </select>
                </div>
            </div>

            <div class="form-group" hidden="hidden">
                <label class="col-sm-3 control-label">所在仓库ID：</label>
                <div class="col-sm-8">
                    <input name="stockHouseId" th:field="*{stockHouseId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group" hidden="hidden">
                <label class="col-sm-3 control-label">仓库名称：</label>
                <div class="col-sm-8">
                    <input name="stockHouseName" th:field="*{stockHouseName}" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">物料属性：</label>
                <div class="col-sm-8">
                    <input name="materialProperties" th:field="*{materialProperties}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">物料名称：</label>
                <div class="col-sm-8">
                    <input name="materialName" th:field="*{materialName}" class="form-control" type="text">
                </div>
            </div>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "warehouse/stock";
        $("#form-stock-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-stock-edit').serialize());
            }
        }

        $("input[name='inStockDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        function chosseVal() {
            var checkText=$("#selectWare").find("option:selected").text();  //获取Select选择的Text
            var checkValue=$("#selectWare").val();  //获取Select选择的Value
            console.log(checkText,checkValue);
            $('#stockHouseId').val(checkValue);
            $('#stockHouseName').val(checkText);
        };
    </script>
</body>
</html>